﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MSTR.IS.Util
{
    public static class Cleaner
    {
        /// <summary>
        /// Set text to empty for specified text controls.
        /// </summary>
        /// <param name="textControls">The text controls.</param>
        /// <exception cref="ArgumentException" />
        public static void ClearText(params ITextControl[] textControls)
        {
            if (Common.IsNullOrEmpty(textControls))
                throw new ArgumentException("At least specify one text control.", "textControls");

            foreach (var control in textControls)
            {
                if (null != control)
                    control.Text = string.Empty;
            }
        }

        /// <summary>
        /// Clear the selection for specified list controls.
        /// </summary>
        /// <param name="listControls">The list controls.</param>
        /// <exception cref="ArgumentException" />
        public static void ClearSelection(params ListControl[] listControls)
        {
            if (Common.IsNullOrEmpty(listControls))
                throw new ArgumentException("At least specify one list control.", "listControls");

            foreach (var control in listControls)
            {
                if (null != control)
                    control.ClearSelection();
            }
        }
    }
}
